Create or update a resource service extension.
rest-admin
role, or the
following privileges:
http://marklogic.com/xdmp/privileges/rest-admin
http://marklogic.com/xdmp/privileges/rest-writer
http://marklogic.com/xdmp/privileges/rest-reader
# Note: Use --data-binary instead of -d with curl to preserve newlines # in the input, such as line-oriented comments (//). $ curl --anyauth --user user:password -X PUT -i \ -H "Content-type: application/vnd.marklogic-javascript" \ --data-binary @"./example.sjs" \ 'http://localhost:8004/v1/config/resources/example' ==> A JavaScript resource addressable through /v1/resources/example. MarkLogic Server returns the following headers: Server: MarkLogic Content-Type: text/xml; charset=UTF-8 Content-Length: 211 Connection: close HTTP/1.1 204 Created Server: MarkLogic Content-Type: text/plain; charset=UTF-8 Content-Length: 4 Connection: close
$ curl --anyauth --user user:password -X PUT -i \ -H "Content-type: application/xquery" -d@"./example.xqy" \ 'http://localhost:8004/v1/config/resources/example' ==> An XQuery resource addressable through /v1/resources/example. MarkLogic Server returns the following headers: Server: MarkLogic Content-Type: text/xml; charset=UTF-8 Content-Length: 211 Connection: close HTTP/1.1 204 Created Server: MarkLogic Content-Type: text/plain; charset=UTF-8 Content-Length: 4 Connection: close
$ curl --anyauth --user user:password -X PUT -i \ -H "Content-type: application/xquery" -d@"./example.xqy" \ 'http://localhost:8004/v1/config/resources/example?method=get&get:the-uri=string&provider=Acme Widgets' ==> An XQuery resource addressable through /v1/resources/example. The metadata for the extension will include parameter name and type information for the GET method. MarkLogic Server returns the following headers: Server: MarkLogic Content-Type: text/xml; charset=UTF-8 Content-Length: 211 Connection: close HTTP/1.1 204 Created Server: MarkLogic Content-Type: text/plain; charset=UTF-8 Content-Length: 4 Connection: close
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.